#include <QtCore>
#include "figurefactory.h"

#include "figures/pawn.h"
#include "figures/knight.h"
#include "figures/rook.h"
#include "figures/bishop.h"
#include "figures/queen.h"
#include "figures/king.h"


BoardFigure* FigureFactory::createFigure( int x, int y, QString type, int color )
{
  QString figureColor = (color == Constants::COLOR_WHITE) ? ( QString("white") ) : ( QString("black") ); 
  QString picPath = QString(":/pics/%1-%2.svg").arg( figureColor ).arg( type ); 
  qDebug() << "Creating figure";

  if ( type == "pawn" ) {
    return new Pawn( x, y, picPath, color );
  }
  else if ( type == "rook" ) {
    return new Rook( x, y, picPath, color );
  }
  else if ( type == "knight" ) {
    return new Knight( x, y, picPath, color );
  }
  else if ( type == "bishop" ) {
    return new Bishop( x, y, picPath, color );
  }
  else if ( type == "queen" ) {
    return new Queen( x, y, picPath, color );
  }
  else if ( type == "king" ) {
    return new King( x, y, picPath, color );
  }
  else {
    Q_ASSERT_X( true, "FigureFactory", "Unknown figure type" );
  }

  //
  // TODO: Make exception
  //
  return 0;
}
